package com.czz.manage.controller.teacher;

import com.czz.common.exception.ResultCodeEnum;
import com.czz.common.vo.R;
import com.czz.manage.service.DailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName: DailyTeacherController
 * @Author Czz
 * @Date 2020/3/13
 * @Time 12:24
 **/
@RestController
@RequestMapping(value = "/teacher/daily")
public class DailyTeacherController {

    @Autowired
    DailyService dailyService;

    /**
    * @Description 讲师数据报表
    * @Param [begin, end, type]
    * @Return com.czz.common.vo.R
    * @Author Czz
    * @Date 2020/3/13
    * @Time 13:17
    **/
    @GetMapping(value = "/{teacherId}/{begin}/{end}/{type}")
    public R getDailyChart(@PathVariable String teacherId, @PathVariable String begin, @PathVariable String end, @PathVariable String type){
        if (StringUtils.isEmpty(teacherId) || StringUtils.isEmpty(begin) || StringUtils.isEmpty(end) || StringUtils.isEmpty(type)){
            return R.setResult(ResultCodeEnum.INPUT_ERROR);
        }
        List<Map<String, String>> mapList = dailyService.getTeacherDailyChart(teacherId, begin, end, type);
        return R.ok().data("item",mapList);
    }
}
